package training.sample.app.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import training.sample.app.domain.UserAccount;
import training.sample.app.repository.UserDao;
import training.sample.app.service.UserService;

@Service
@Transactional
public class UserServiceImpl implements UserService {
	
	@Autowired
	private UserDao userRepository;
	
	public UserAccount loadUserByCredentials(String login, String password) {

		UserAccount user = userRepository.findByCredentials(login, password);
		return user;
	}

	public UserAccount getUserByID(Long userId) {
		UserAccount user = userRepository.findById(new Long(userId));
		return user;
	}

	@Override
	public void logoutUser(Long userId) {
	}

	@Override
	public UserAccount loadUserDetailsByLogin(String login) {
		return userRepository.findByLogin(login);
	}

}
